package com.bankcomm.ui.views;

import com.bankcomm.util.LPUtils;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;

/**
 *仿SlidingMenu菜单控件 修改为垂直方向
 *
 *@add by sun_t 2014.01.15
 * */
public class VerticalSlidingMenu extends LinearLayout {
	private VerticalSlidingView sv;
	
	/**
	 * 两边菜单设为屏幕宽度的3/4
	 * */
	int height = 0;
	
	public VerticalSlidingMenu(Context context) {
		super(context);
		init(context);
	}

	public VerticalSlidingMenu(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}

	private void init(Context context) {
		this.setOrientation(LinearLayout.VERTICAL);
		
		sv = new VerticalSlidingView(context);
	}
	
	/**
	 * 添加View,上、下
	 * */
	public void addViews(View top, View center) {
		sv.setLLinnerParams();
		setTopView(top);
		setCenterView(center);
		invalidate();
	}
	
	/**
	 * 添加View，上
	 * */
	public void setTopView(View view) {
		View v = view;
		sv.setMenuView(v);
	}
	
	/**
	 * 添加View，中
	 * */
	public void setCenterView(View view) {
		View v = view;
		sv.setMainView(v);
		sv.scrollTo(0, 0);
	}

	/**
	 * 获取广告与菜单栏高度
	 */
	public void getCenterHeight(int height) {
		this.height = height;
		sv.getMenuViewHeight(height);
	}
	
	public void addScrollView(){
		LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LPUtils.screenheight + height);
		// 禁止垂直滚动条
		sv.setVerticalScrollBarEnabled(false);
		// 禁止水平滚动条
		sv.setHorizontalScrollBarEnabled(false);
		this.addView(sv, lp);
	}

	
	/**
	 * 显示View，顶部
	 * */
	public void showTopView() {
		sv.showTopView();
	}
	
	public void setMenuListener(OnMenuListener listener){
		sv.setListener(listener);
	}
	
	/**
	 * SlidingMenu菜单事件
	 * */
	public interface OnMenuListener{
		public void openMenu(boolean isOpen);
	}
	
}
